package com.acwing.partition15;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

/**
 * @author `RKC`
 * @date 2022/2/13 19:32
 */
public class AC1460我在哪 {

    private static final int N = 110, P = 131;
    private static long[] s = new long[N], h = new long[N];
    private static Set<Long> set = new HashSet<>();
    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        //找到一个k，使得所有长为k的子串互不相同
        n = Integer.parseInt(reader.readLine());
        String s = reader.readLine();
        hash(s);
        int l = 1, r = n - 1;
        while (l < r) {
            int mid = l + r >> 1;
            if (check(s, mid)) r = mid;
            else l = mid + 1;
        }
        writer.write(l + "\n");
        writer.flush();
    }

    private static boolean check(String str, int len) {
        set.clear();
        for (int i = 0; i + len - 1 < str.length(); i++) {
            int l = i + 1, r = i + len;
            long k = get(l, r);
            if (set.contains(k)) return false;
            set.add(k);
        }
        return true;
    }

    private static long get(int l, int r) {
        return h[r] - h[l - 1] * s[r - l + 1];
    }

    private static void hash(String str) {
        s[0] = 1;
        for (int i = 1; i <= n; i++) {
            s[i] = s[i - 1] * P;
            h[i] = h[i - 1] * P + str.charAt(i - 1);
        }
    }
}
